package clientTest;

import org.apache.http.HttpHost;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.junit.Test;

import java.io.IOException;

public class TestClient {

    @Test
    public void test() throws IOException {
        RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost("192.168.153.131", 9200, "http")));
        GetRequest getRequest = new GetRequest("test7", "user", "3");
        boolean exists = client.exists(getRequest, RequestOptions.DEFAULT);
        if (exists)
            System.out.println("exists");
        else
            System.out.println("not exists");
        client.close();
    }
}
